import time

from selenium.webdriver.support.wait import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

class Base():
    def __init__(self,driver):
        self.driver=driver

    def get_url(self,url):
        self.driver.get(url)

    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,10).until(EC.presence_of_element_located(loc))
            return self.driver.find_element(*loc)
        except Exception as e:
            print(e)
    def click(self,loc):
        self.find_element(loc).click()
    def send_keys(self,loc,txt):
        self.find_element(loc).send_keys(txt)
    def window_frame(self,loc):
        ele = self.find_element(loc)
        self.driver.switch_to.frame(ele)
    def jietu(self,name):
        t = time.strftime('%Y%m%d%H%M%S',time.localtime())
        self.driver.save_screenshot(t+name )
